/*
CREDITS:
INFO - Frankensprite - a sprite made of parts of other sprites.
Just like frankenstein is a mashup of other people's limbs. Crazy, eh?

Sprites:
Frankensprite - Ryan Cordell, I hope. Bits from 3DRealms work. (Shadow Warrior)
Smoke, ring - Smoke is definitely from Doom 3... not sure about the ring

Sounds:
Up - Epic Games (UT2004)
Fire - sounds like it's Quake 2, but it ain't a one... not sure if edited, or from some other game.
Add - ID (Quake 4)
Fly - Valve (Half-Life 2)
Hit - ?
Zoom in, Zoom out - ID (ET:QW)
*/

ACTOR Instafun : DoomWeapon 24524
{
   //$Category Weapons
   //$Title Instafuneral
   //$Sprite FUNGX0
   Tag "Instafuneral"
   Inventory.PickupSound "misc/w_pkup"
   Inventory.PickupMessage "Mumbling in joy  at ''Instafuneral'' tri-shockrifle! No need for ceremonials - your death will be swift, and with style. (7)" //feel the "Allo Allo" reference!
   Obituary "%o's funeral was shockingly fast executed by %k."
   Weapon.UpSound "Weapons/InstafunUp"
   Weapon.SelectionOrder 2
   Weapon.AmmoType "IonAmmo"
   Weapon.AmmoGive 12
   Weapon.AmmoUse 1
   Weapon.AmmoType2 "IonAmmo"
   Weapon.AmmoUse2 3
   Weapon.Kickback 70
   Weapon.SlotNumber 7
   Weapon.BobStyle InverseSmooth
   Weapon.BobSpeed 1.4
   Weapon.BobRangeY 0.6
   Weapon.BobRangeX 1.2
   Scale 0.85
   +NOALERT
   +NOAUTOFIRE
   States
   {
   Spawn:
      FUNG X -1
      Loop
   Ready:
      FUNG A 0 A_JumpIfInventory("Zoomed",1,"ZoomedReady")
      FUNG A 1 A_WeaponReady(WRF_ALLOWZOOM)
      Loop
   ZoomedReady:
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ A 0 A_SetBlend("Green",0.025,3)
      FUNZ A 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
      Goto Ready
   Select:
      FUNF A 0 A_TakeInventory("Zoomed",999)
      FUNF A 0 A_TakeInventory("FireCounter",3)
      FUNF A 0 A_GiveInventory("FireCounter",1)
   SelectinARiver:
      FUNG A 1 A_Raise
      Loop
   Deselect:
      FUNG A 0 A_ZoomFactor(1)
      FUNG A 0 A_JumpIfInventory("Zoomed",1,"ZoomedDeselect")
      FUNG A 0 A_SetTranslucent(1,0)
      FUNG A 1 A_Lower
      FUNG A 0 A_Lower
      Loop
   Fire:
      FUNG A 0 A_JumpIfInventory("Zoomed",1,"ZoomedFire")
      FUNG A 4 A_GunFlash
      
   Hold:
      FUNG A 0 A_JumpIfInventory("Zoomed",1,"ZoomedHold")
      FUNF A 0 A_GiveInventory("FireCounter",1)
      FUNF A 0 A_AlertMonsters
      FUNF A 0 A_Recoil(1)
      FUNF A 0 A_PlaySound("Weapons/InstafunAddFire",6,0.7)
      FUNG A 0 A_JumpIfInventory("FireCounter",3,"FireBarrel1")
      FUNG A 0 A_JumpIfInventory("FireCounter",2,"FireBarrel3")
      FUNG A 0 A_JumpIfInventory("FireCounter",1,"FireBarrel2")
      Goto FireBarrel3
   FireBarrel1:
      FUN1 A 0 A_TakeInventory("FireCounter",3)
      FUNF A 0 A_PlaySound("Weapons/InstafunFire",5,0.7)
      FUN1 A 0 A_FireCustomMissile("InstafunProjectile",2,1,5,-1,0,0)
      FUN1 D 1 BRIGHT A_ZoomFactor(0.99)
      FUNF A 0 A_SetAngle(angle-0.15)
      FUNF A 0 A_SetPitch(pitch-0.25)
      FUN1 E 1 BRIGHT A_ZoomFactor(0.98)
      FUNF A 0 A_SetAngle(angle-0.05)
      FUNF A 0 A_SetPitch (pitch-0.1)
      FUN1 F 1 BRIGHT A_ZoomFactor(0.96)
      FUN1 A 0 A_SetPitch (pitch-0.1)
      
      FUN1 F 1 A_ZoomFactor(0.95)
      FUN1 F 1 A_ZoomFactor(0.96)
      FUN1 D 0 A_ReFire
      Goto FireMain
   FireBarrel2:
      FUN2 A 0 A_PlaySound("Weapons/InstafunFire",8,0.7)
      FUN2 A 0 A_FireCustomMissile("InstafunProjectile",0,1,10,-1,0,0)
      FUN2 D 1 BRIGHT A_ZoomFactor(0.99)
      FUNF A 0 A_SetAngle(angle-0.15)
      FUNF A 0 A_SetPitch(pitch-0.25)
      FUN2 E 1 BRIGHT A_ZoomFactor(0.98)
      FUNF A 0 A_SetAngle(angle-0.05)
      FUNF A 0 A_SetPitch (pitch-0.1)
      FUN2 F 1 BRIGHT A_ZoomFactor(0.96)
      FUN1 A 0 ACS_Execute(851,0,0,5)
      FUN2 A 0 A_SetPitch (pitch-0.1)
      
      FUN2 F 1 A_ZoomFactor(0.95)
      FUN2 F 1 A_ZoomFactor(0.96)
      FUN2 D 0 A_ReFire
      Goto FireMain
   FireBarrel3:
      FUN2 A 0 A_PlaySound("Weapons/InstafunFire",1,0.7)
      FUNF A 0 A_FireCustomMissile("InstafunProjectile",-2,1,15,-1,0,0)
      FUNF D 1 BRIGHT A_ZoomFactor(0.99)
      FUNF A 0 A_SetAngle(angle-0.15)
      FUNF A 0 A_SetPitch(pitch-0.25)
      FUNF E 1 BRIGHT A_ZoomFactor(0.98)
      FUNF A 0 A_SetAngle(angle-0.05)
      FUNF A 0 A_SetPitch (pitch-0.1)
      FUNF F 1 BRIGHT A_ZoomFactor(0.96)
      FUNF A 0 A_SetPitch (pitch-0.1)
      
      FUNF F 1 A_ZoomFactor(0.95)
      FUNF F 1 A_ZoomFactor(0.96)
      FUNF D 0 A_ReFire
      Goto FireMain
   FireMain:
      FUN1 E 1 A_ZoomFactor(0.97)
      FUN1 D 1 A_ZoomFactor(0.98)
      FUNF C 1 A_ZoomFactor(0.985)
      FUNF B 1 A_ZoomFactor(0.99)
      FUNF A 1 A_ZoomFactor(0.995)
      FUNG A 1 A_ZoomFactor(1)
      
      FUNG A 0 A_ReFire

      FUNG A 2
      Goto Ready
   AltFire:
      FUNZ A 0 A_JumpIfInventory("MagnetCooldown",1,"Ready")
      FUNG A 0 A_JumpIfInventory("Zoomed",1,"ZoomedAltFire")
      FUNF A 0 A_Recoil(20)
      FUNF A 0 A_GiveInventory("MagnetCooldown",105)
      FUNF A 0 A_SetBlend("Cyan",0.8,25)
      FUNF A 0 A_PlaySound("Weapons/InstafunAddFire",6,0.7)
      FUNF A 0 A_PlaySound("Instafun/MagnetFire",5,0.9)
      FUNF A 0 A_FireCustomMissile("MagnetProjectile",0,1,10,-1,0,0)
	  
      //FUNF A 0 A_PlaySound("Weapons/InstafunFire",0)

      //FUN1 A 0 A_FireCustomMissile("InstafunProjectile",2,1,5,-1,0,0)
      //FUN2 A 0 A_FireCustomMissile("InstafunProjectile",0,0,10,-1,0,0)
      //FUNF A 0 A_FireCustomMissile("InstafunProjectile",-2,0,15,-1,0,0)


      FUNA D 1 BRIGHT A_ZoomFactor(0.96)
      FUNF A 0 A_AlertMonsters
      FUNF A 0 A_SetAngle(angle-4)
      FUNF A 0 A_SetPitch (pitch-4)

      FUNA E 1 BRIGHT A_ZoomFactor(0.95)
      FUNF A 0 A_SetAngle(angle-2)
      FUNF A 0 A_SetPitch (pitch-2)

      FUNA F 1 BRIGHT A_ZoomFactor(0.945)
      FUNF A 0 A_SetAngle(angle-0.5)
      FUNF A 0 A_SetPitch (pitch-0.5)
      
      FUNA F 1 A_ZoomFactor(0.95)
      FUNF A 0 A_SetAngle(angle-0.25)
      FUNF A 0 A_SetPitch (pitch-0.25)
      FUNA F 1 A_ZoomFactor(0.96)
      FUNF A 0 A_SetAngle(angle-0.15)
      FUNF A 0 A_SetPitch (pitch-0.15)
      FUNA E 1 A_ZoomFactor(0.97)
      FUNF A 0 A_SetAngle(angle-0.1)
      FUNF A 0 A_SetPitch (pitch-0.1)
      FUNA D 1 A_ZoomFactor(0.98)

      FUNF C 1 A_ZoomFactor(0.985)
      FUNF B 1 A_ZoomFactor(0.99)
      FUNF A 1 A_ZoomFactor(0.995)
      FUNG A 1 A_ZoomFactor(1)
      Goto Ready

   Flash:
       FUNL ABCD 1 Bright
       Stop
       
   UnZoom:
      FUNZ A 0 A_PlaySound("Weapons/InstafunZoomOut",5,0.7)
      FUNZ A 0 A_TakeInventory("Zoomed",999)

      FUNZ A 0 A_SetTranslucent(0.9,0)
      FUNZ B 1 A_SetBlend("Black",0.35,3) 
      
      FUNZ A 0 A_SetTranslucent(0.92,0)
      FUNZ B 1 A_SetBlend("Black",0.4,3)
      
      FUNZ A 0 A_SetTranslucent(0.94,0)
      FUNZ B 1 A_SetBlend("Black",0.45,3)
      FUNZ A 0 A_ZoomFactor(1.00)
      
      FUNZ A 0 A_SetTranslucent(0.96,0)
      FUNZ B 1 A_SetBlend("Black",0.6,3)
      
      FUNZ A 0 A_SetTranslucent(0.98,0)
      FUNZ B 1 A_SetBlend("Black",0.75,3)
      
      FUNZ A 0 A_SetTranslucent(1,0)
      FUNZ B 1 A_SetBlend("Black",0.9,3)
      
      FUNG A 16 A_SetBlend("Black",1.1,25)
      Goto Ready
  ZoomedDeselect:
      FUNZ A 0 A_PlaySound("Weapons/InstafunZoomOut",5)
      FUNZ A 0 A_TakeInventory("Zoomed",999)

      FUNZ A 0 A_SetTranslucent(0.9,0)
      FUNZ B 1 A_SetBlend("Black",0.35,3) 
      
      FUNZ A 0 A_SetTranslucent(0.92,0)
      FUNZ B 1 A_SetBlend("Black",0.4,3)
      
      FUNZ A 0 A_SetTranslucent(0.94,0)
      FUNZ B 1 A_SetBlend("Black",0.45,3)
      FUNZ A 0 A_ZoomFactor(1.00)
      
      FUNZ A 0 A_SetTranslucent(0.96,0)
      FUNZ B 1 A_SetBlend("Black",0.6,3)
      
      FUNZ A 0 A_SetTranslucent(0.98,0)
      FUNZ B 1 A_SetBlend("Black",0.75,3)
      
      FUNZ A 0 A_SetTranslucent(1,0)
      FUNZ B 1 A_SetBlend("Black",0.9,3)
      
      FUNZ BBBBBBBBBB 1 A_SetBlend("Black",1,3)
      
      FUNG A 16 A_SetBlend("Black",1.1,25)
  ZoomedDeselectMain:
      FUNG A 1 A_Lower
      FUNG A 0 A_Lower
      Loop

   ZoomedFire:
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)
            
   ZoomedHold:
      FUNG A 0 A_JumpIfInventory("FireCounter",3,"ZoomedFireBarrel1")
      FUNG A 0 A_JumpIfInventory("FireCounter",2,"ZoomedFireBarrel3")
      FUNG A 0 A_JumpIfInventory("FireCounter",1,"ZoomedFireBarrel2")
      Goto ZoomedFireBarrel3
      
   ZoomedFireBarrel1:
      FUNF A 0 A_TakeInventory("FireCounter",3)
      FUNZ A 0 A_PlaySound("Weapons/InstafunFire",5,0.7)
      FUNF A 0 A_FireCustomMissile("InstafunProjectile",0,1,-8,0,0,0)
      Goto ZoomedFireMain
   ZoomedFireBarrel2:
      FUNZ A 0 A_PlaySound("Weapons/InstafunFire",8,0.7)
      FUNF A 0 A_FireCustomMissile("InstafunProjectile",0,1,-4,0,0,0)
      Goto ZoomedFireMain
   ZoomedFireBarrel3:
      FUNZ A 0 A_PlaySound("Weapons/InstafunFire",1,0.7)
      FUNF A 0 A_FireCustomMissile("InstafunProjectile",0,1,-2,0,0,0)
      Goto ZoomedFireMain
      
   ZoomedFireMain:
      FUNZ A 0 A_GiveInventory("FireCounter",1)
      FUNZ A 0 A_Recoil(0.5)
	  FUNZ A 0 A_AlertMonsters
      FUNZ A 0 A_PlaySound("Weapons/InstafunAddFire",6,0.8)


      FUNZ A 0 A_SetPitch (pitch-0.25)
      FUNZ A 0 A_ZoomFactor(2.99)	//FUNF D
      FUNZ B 1 Bright A_SetBlend("Blue",0.1,20)

      FUNZ A 0 A_SetPitch (pitch-0.25)
      FUNZ B 0 A_ZoomFactor(2.95)	//FUNF E
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 Bright A_SetBlend("Blue",0.05,3)

      FUNZ A 0 A_SetPitch (pitch+0.25)
      FUNZ B 0 A_ZoomFactor(2.925)	//FUNF F
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 Bright A_SetBlend("Blue",0.025,3)

      FUNZ A 0 A_SetPitch (pitch+0.15)
      FUNZ A 0 A_ZoomFactor(2.94)	//FUNF F
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)
      
      FUNZ A 0 A_SetPitch (pitch+0.1)
      FUNZ A 0 A_ZoomFactor(2.95)	//FUNF F
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)

      FUNZ A 0 A_ReFire

      FUNZ A 0 A_ZoomFactor(2.96)	//FUNF E
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)

      FUNZ B 0 A_ZoomFactor(2.97)	//FUNF D
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)

      FUNZ B 0 A_ZoomFactor(2.98)	//FUNF C
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)

      FUNZ B 0 A_ZoomFactor(2.99)	//FUNF B
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)

      FUNZ B 1 A_ZoomFactor(2.995)	//FUNF A
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)

      FUNZ B 0 A_ZoomFactor(3)		//FUNG A
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)

      FUNZ A 0 A_ReFire

      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ A 1 A_SetBlend("Green",0.025,3)
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ A 1 A_SetBlend("Green",0.025,3)
      Goto Ready
   ZoomedAltFire:
      FUNZ A 0 A_JumpIfInventory("MagnetCooldown",1,"ZoomedReady")
      FUNZ A 0 A_Recoil(1.5)
      FUNZ A 0 A_GiveInventory("MagnetCooldown",105)
      FUNZ A 0 A_PlaySound("Weapons/InstafunAddFire",6,0.7)
      FUNZ A 0 A_PlaySound("Instafun/MagnetFire",5,0.9)
      FUNZ A 0 A_FireCustomMissile("MagnetProjectile",0,1,-4,0,0,0)
	  /*
      FUNZ A 0 A_PlaySound("Weapons/InstafunFire",0)

      FUNF A 0 A_FireCustomMissile("InstafunProjectile",-0.5,1,-8,0,0,0)
      FUNF A 0 A_FireCustomMissile("InstafunProjectile",0,0,-4,0,0,0)
      FUNF A 0 A_FireCustomMissile("InstafunProjectile",0.5,0,-2,0,0,0)
	  */
      FUNZ A 0 A_SetPitch (pitch-3)
      FUNZ A 0 A_ZoomFactor(2.97)	//FUNF D
      FUNZ B 1 Bright A_SetBlend("Blue",0.1,20)
	  FUNZ A 0 A_AlertMonsters

      FUNZ A 0 A_SetPitch (pitch-2)
      FUNZ B 0 A_ZoomFactor(2.925)	//FUNF E
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 Bright A_SetBlend("Blue",0.05,3)

      FUNZ A 0 A_SetPitch (pitch-1)
      FUNZ B 0 A_ZoomFactor(2.9)	//FUNF F
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 Bright A_SetBlend("Blue",0.025,3)

      FUNZ A 0 A_SetPitch (pitch-0.25)
      FUNZ A 0 A_ZoomFactor(2.91)	//FUNF F
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)
      FUNZ A 0 A_SetPitch (pitch+0.35)

      FUNZ A 0 A_SetPitch (pitch-0.15)
      FUNZ A 0 A_ZoomFactor(2.925)	//FUNF F
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)

      FUNZ A 0 A_ZoomFactor(2.95)	//FUNF E
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)

      FUNZ B 0 A_ZoomFactor(2.96)	//FUNF D
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)

      FUNZ B 0 A_ZoomFactor(2.97)	//FUNF C
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)

      FUNZ B 0 A_ZoomFactor(2.98)	//FUNF B
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)

      FUNZ B 1 A_ZoomFactor(2.99)	//FUNF A
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)

      FUNZ B 0 A_ZoomFactor(3)		//FUNG A
      FUNZ A 0 A_SetBlend("Black",0.3,3)
      FUNZ B 1 A_SetBlend("Green",0.025,3)
      Goto Ready
   Zoom:
      FUNG A 0 A_JumpIfInventory("Zoomed",1,"UnZoom")

      FUNG A 0 A_GiveInventory("Zoomed",1)
      FUNG A 0 A_PlaySound("Weapons/InstafunZoomIn",5,0.7)

      FUNG A 1 A_SetBlend("Black",0.15,3)
      FUNG A 1 A_SetBlend("Black",0.3,3)
      FUNG A 1 A_SetBlend("Black",0.45,3)
      FUNG A 1 A_SetBlend("Black",0.6,3)
      FUNG A 1 A_SetBlend("Black",0.75,3)
      FUNG A 1 A_SetBlend("Black",0.9,3)

      FUNG AAAAAAAAAA 1 A_SetBlend("Black",1,11)
      
      FUNZ A 0 A_ZoomFactor(3.00)
      FUNZ A 0 A_SetTranslucent(0.98,0)
      FUNZ B 1 A_SetBlend("Black",0.9,3)
      
      FUNZ A 0 A_SetTranslucent(0.96,0)
      FUNZ B 1 A_SetBlend("Black",0.85,3)
      
      FUNZ A 0 A_SetTranslucent(0.84,0)
      FUNZ B 1 A_SetBlend("Black",0.75,3)
      
      FUNZ A 0 A_SetTranslucent(0.82,0)
      FUNZ B 1 A_SetBlend("Black",0.65,3)
      
      FUNZ A 0 A_SetTranslucent(0.81,0)
      FUNZ B 1 A_SetBlend("Black",0.55,3)
      
      FUNZ A 0 A_SetTranslucent(0.8,0)
      FUNZ B 1 A_SetBlend("Black",0.45,3)
      
      FUNZ B 1 A_SetBlend("Black",0.4,3)
      FUNZ B 1 A_SetBlend("Black",0.36,3)
      FUNZ B 1 A_SetBlend("Black",0.34,3)
      FUNZ B 1 A_SetBlend("Black",0.33,3)
      FUNZ B 1 A_SetBlend("Black",0.32,3)
      FUNZ B 1 A_SetBlend("Black",0.31,3)
      Goto ZoomedReady
   }
}

ACTOR FireCounter : Inventory { Inventory.MaxAmount 3 }
ACTOR MagnetCooldown : Inventory { Inventory.MaxAmount 105 }

//Fire
ACTOR InstafunProjectile : FastProjectile
{
  Speed 300
  Radius 14
  Height 9
  Damage 95
  Renderstyle Add
  +RIPPER
  -CANNOTPUSH
  +NODAMAGETHRUST
  +EXTREMEDEATH
  +FORCERADIUSDMG
  +DONTBLAST
  DeathSound "weapons/InstafunHit"
  MissileType "InstafunTrail"
  MissileHeight 9
  Scale 2
  states
  {
  Spawn:
    TNT1 A 0
    TNT1 A 1 A_PlaySoundEx("Weapons/InstafunFly","SoundSlot5",1)
    Loop
  Death:
    TNT1 A 0 A_StopSoundEx("SoundSlot5")
    TNT1 A 0 A_SpawnItemEx("InstafunShock",0,0,0,0,0,0,0,128,0)
    TNT1 AAAAAAAAAA 0 A_SpawnItemEx("InstafunExplode", random(10,-10), random(10,-10), random(5,-5), 0, 0, 0, 0, 128, 0)
    TNT1 A 0 A_Explode(25,128,0,1)
    TNT1 A 2
    TNT1 AAAAAA 0 A_SpawnItemEx("InstafunExplode", random(10,-10), random(10,-10), random(5,-5), 0, 0, 0, 0, 128, 0)
    TNT1 A 0 A_Explode(50,96,0,1)
    TNT1 A 2
    TNT1 AAA 0 A_SpawnItemEx("InstafunExplode", random(10,-10), random(10,-10), random(5,-5), 0, 0, 0, 0, 128, 0)
    TNT1 A 0 A_Explode(75,48,0,1)
    TNT1 A 2

    TNT1 A 0 A_SpawnItemEx("InstafunShock",0,0,0,0,0,0,0,128,0)
    TNT1 AAAAAAAAAA 0 A_SpawnItemEx("InstafunExplode", random(10,-10), random(10,-10), random(5,-5), 0, 0, 0, 0, 128, 0)
    TNT1 A 0 A_Explode(25,128,0,1)
    TNT1 A 2
    TNT1 AAAAAA 0 A_SpawnItemEx("InstafunExplode", random(10,-10), random(10,-10), random(5,-5), 0, 0, 0, 0, 128, 0)
    TNT1 A 0 A_Explode(50,96,0,1)
    TNT1 A 2
    TNT1 AAA 0 A_SpawnItemEx("InstafunExplode", random(10,-10), random(10,-10), random(5,-5), 0, 0, 0, 0, 128, 0)
    TNT1 A 0 A_Explode(75,48,0,1)
    TNT1 A 2

    TNT1 A 0 A_SpawnItemEx("InstafunShock",0,0,0,0,0,0,0,128,0)
    TNT1 AAAAAAAAAA 0 A_SpawnItemEx("InstafunExplode", random(10,-10), random(10,-10), random(5,-5), 0, 0, 0, 0, 128, 0)
    TNT1 A 0 A_Explode(25,128,0,1)
    TNT1 A 2
    TNT1 AAAAAA 0 A_SpawnItemEx("InstafunExplode", random(10,-10), random(10,-10), random(5,-5), 0, 0, 0, 0, 128, 0)
    TNT1 A 0 A_Explode(50,96,0,1)
    TNT1 A 2
    TNT1 AAA 0 A_SpawnItemEx("InstafunExplode", random(10,-10), random(10,-10), random(5,-5), 0, 0, 0, 0, 128, 0)
    TNT1 A 0 A_Explode(75,48,0,1)
    TNT1 A 2
    stop
  }
}

ACTOR InstafunExplode
{
  Radius 17
  Height 10
  Renderstyle Add
  Scale 0.5
  Alpha 0.5
  +CLIENTSIDEONLY
  +NOINTERACTION
  +NOGRAVITY
  states
  {
  Spawn:
    FUNE ABCDEF 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.75), 0)
    FUNE G 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.75), 0)
    FUNP A 0 A_FadeOut(0.05)
    FUNE H 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.75), 0)
    FUNP A 0 A_FadeOut(0.05)
    FUNE I 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.75), 0)
    FUNP A 0 A_FadeOut(0.05)
    FUNE J 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.75), 0)
    FUNP A 0 A_FadeOut(0.05)
    FUNE K 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.75), 0)
    FUNP A 0 A_FadeOut(0.05)
    FUNE L 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.75), 0)
    FUNP A 0 A_FadeOut(0.05)
    FUNE M 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.75), 0)
    FUNP A 0 A_FadeOut(0.05)
    FUNE N 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.75), 0)
    FUNP A 0 A_FadeOut(0.05)
    FUNE O 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.75), 0)
    FUNP A 0 A_FadeOut(0.05)
    FUNE P 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.75), 0)
    FUNP A 0 A_FadeOut(0.05)
    stop
  }
}

ACTOR InstafunShock
{
  Renderstyle Add
  Scale 0
  Alpha 1
  +CLIENTSIDEONLY
  +NOINTERACTION
  +NOGRAVITY
  states
  {
  Spawn:
    FUNP A 0
    FUNP A 0 A_SetScale(ScaleX +0.1, ScaleY +0.1)
    FUNP A 1 bright A_FadeOut(0.05)
    Loop
  }
}

ACTOR InstafunTrail
{
  RenderStyle Add
  Scale 0.1
  +CLIENTSIDEONLY
  +NOINTERACTION
  +NOGRAVITY
  States
  {
  Spawn:
    FUNP A 0
    //TNT1 A 0 A_SpawnItemEx("InstafunFlame", random(8,-8), random(8,-8), random(8,-8), 0, 0, 0, 0, 128, 0)
    FUNP A 0 A_SetScale(ScaleX +0.02, ScaleY +0.02)
    FUNP A 1 bright A_FadeOut(0.075)
    FUNP A 0 A_SetScale(ScaleX +0.02, ScaleY +0.02)
    FUNP A 1 bright A_FadeOut(0.075)
    Loop
  }
}

ACTOR InstafunFlame
{
  Radius 17
  Height 10
  Renderstyle Add
  Scale 0.3
  Alpha 0.15
  +CLIENTSIDEONLY
  +NOINTERACTION
  +NOGRAVITY
  states
  {
  Spawn:
    FUNE ABCDEF 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.25), 0)
    FUNE G 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.25), 0)
    FUNP A 0 A_FadeOut(0.025)
    FUNE H 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.25), 0)
    FUNP A 0 A_FadeOut(0.025)
    FUNE I 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.25), 0)
    FUNP A 0 A_FadeOut(0.035)
    FUNE J 2 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.25), 0)
    FUNP A 0 A_FadeOut(0.025)
    FUNE K 3 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.25), 0)
    FUNP A 0 A_FadeOut(0.035)
    FUNE L 3 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.25), 0)
    FUNP A 0 A_FadeOut(0.025)
    FUNE M 3 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.25), 0)
    FUNP A 0 A_FadeOut(0.035)
    FUNE N 3 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.25), 0)
    FUNP A 0 A_FadeOut(0.025)
    FUNE O 3 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.25), 0)
    FUNP A 0 A_FadeOut(0.035)
    FUNE P 3 bright A_ChangeVelocity (frandom(-0.5, 0.5), frandom(-0.5, 0.5), frandom(-0.25, 0.25), 0)
    FUNP A 0 A_FadeOut(0.025)
    stop
  }
}

ACTOR MagnetProjectile
{
  Projectile
  Radius 10
  Height 16
  Damage 2
  Speed 5
  RenderStyle Add
  Scale 0.3
  +NOGRAVITY
  +RIPPER
  +BLOODLESSIMPACT
  Alpha 0.9
  States
  {
  Spawn:
    FUNP AA 0 A_PlaySound("Instafun/MagnetFly",5,1.0,1)
	FUNP AAAAA 0 A_SpawnItemEx("InstafunFlame",random(10,-10),random(10,-10),random(10,-10),0,0,0,0,SXF_CLIENTSIDE)
    FUNP AA 0 A_SpawnItemEx("MagnetParticle",random(8,-8),random(8,-8),random(8,-8),frandom(0.5,-0.5),frandom(0.5,-0.5),frandom(1.0,4.0),random(150,210),SXF_CLIENTSIDE)
    FUNP A 0 A_SpawnItemEx("MagnetWave",0,0,0,0,0,0,0,SXF_CLIENTSIDE,64)
	FUNP AA 0 A_SpawnItemEx("MagnetLaser",random(3,-3),random(3,-3),0,0,0,0,0,SXF_TRANSFERPOINTERS,128)
    FUNP A 1 bright
    Loop
  Death:
    FUNP A 0 A_PlaySound("Instafun/MagnetDeath",5,0.9)
  Looplet:
	FUNP A 0 A_SpawnItemEx("MagnetDeathWeave",0,0,0,0,0,0,0,SXF_CLIENTSIDE)
    FUNP A 0 A_SpawnItemEx("MagnetDeathParticle",0,0,0,0,0,0,0,SXF_CLIENTSIDE)
    FUNP A 0 A_SpawnItemEx("MagnetDeathSmoke",0,0,0,0,0,0,0,SXF_CLIENTSIDE)
	FUNP A 0 A_SpawnItemEx("MagnetDeathGLDEF",0,0,0,0,0,0,0,SXF_CLIENTSIDE)
    Stop
  }
}

ACTOR MagnetLaser
{  
    MONSTER
    Radius 1
    Height 1
    Speed 0
    +NOGRAVITY
    +NOINTERACTION
    +FRIENDLY
    +LOOKALLAROUND
	+QUICKTORETALIATE
	+MISSILEMORE
	+MISSILEEVENMORE //not sure if it actually does anything, as it uses melee, buuuut... if it increases aggresiveness, I'm in.
	+NEVERRESPAWN
	-SOLID
	-SHOOTABLE
	+NEVERTARGET
	MeleeRange 486
    States
	  {
    Spawn:
	   TNT1 A 0
       TNT1 AA 1 A_Look
       Stop
	See:
       TNT1 AA 1 A_Chase("Lazor",0)
	   Stop
    Lazor:
	   TNT1 A 0 A_FaceTarget
       TNT1 A 0 A_CustomRailgun(90,0,"None","Blue",RGF_SILENT|RGF_FULLBRIGHT,1,0,"MagnetPuff",0,0,512,0,10.0,0.0,"MagnetRailParticleSpawner",0)
       Stop
	  }
}

ACTOR MagnetPuff : BulletPuff
{
    DamageType "Nope"
	States
	{
	Spawn:
	TNT1 A 0
	Stop
	}
}

ACTOR MagnetWave
{
  RenderStyle Add
  Scale 0.2
  +CLIENTSIDEONLY
  +NOINTERACTION
  +NOGRAVITY
  Alpha 0.99
  States
  {
  Spawn:
    FUNP AA 0 A_SetScale(ScaleX +Frandom(0.005,0.01), ScaleX)
    FUNP A 0 A_JumpIf(ScaleX >= 0.4, "Decrease")
    FUNP A 1 bright A_FadeOut(frandom(0.05,0.025))
    Loop
  Decrease:
    FUNP A 0 A_SetScale(ScaleX -Frandom(0.005,0.01), ScaleX)
    FUNP A 0 A_JumpIf(ScaleX <= 0, "NULL")
    FUNP A 1 bright A_FadeOut(frandom(0.05,0.025))
    Loop
  }
}

ACTOR MagnetParticle
{
  RenderStyle Add
  Scale 0
  +CLIENTSIDEONLY
  +NOINTERACTION
  +NOGRAVITY
  Alpha 0.99
  States
  {
  Spawn:
    FUNP AA 0 A_SetScale(ScaleX + Frandom(0.05,0.035), ScaleX)
  Looplet:
	FUNP A 0 A_ChangeVelocity(VelX, VelX, VelZ - FRandom(0.1, 0.2), CVF_REPLACE)
    FUNP A 0 A_SetScale(ScaleX -0.001, ScaleX)
    FUNP A 1 bright A_FadeOut(frandom(0.05,0.075))
    Loop
  }
}

ACTOR MagnetRailParticleSpawner
{
  +NOINTERACTION
  +NOGRAVITY
  +CLIENTSIDEONLY
  States
  {
  Spawn:
    FUNP AA 0 A_SpawnItemEx("MagnetRailParticle",30*random(-0.01,0.01),30*random(-0.01,0.01),30*random(-0.01,0.01))
    Stop
  }
}

ACTOR MagnetRailParticle
{
  RenderStyle Add
  Scale 0.1
  +NOINTERACTION
  +NOGRAVITY
  +CLIENTSIDEONLY
  Alpha 0.99
  States
  {
  Spawn:
    FUNP AA 0 A_SetScale(ScaleX -0.01, ScaleX)
    FUNP A 1 bright A_FadeOut(0.1)
    FUNP A 0 A_JumpIf(ScaleX <= 0, "NULL")
    Loop
  }
}

ACTOR MagnetDeathWeave
{
  +NOINTERACTION
  +NOGRAVITY
  +CLIENTSIDEONLY
  States
  {
  Spawn:
    TNT1 AAA 7 A_SpawnItemEx("InstafunShock",0,0,0,0,0,0,0,SXF_CLIENTSIDE,0)
	Stop
  }
}

ACTOR MagnetDeathParticle
{
  RenderStyle Add
  Scale 0.1
  +NOINTERACTION
  +NOGRAVITY
  +CLIENTSIDEONLY
  Alpha 0.99
  var int User_Counter;
  States
  {
  Spawn:
    TNT1 AA 0 A_SetUserVar("User_Counter", 25)
  Looplet:
	TNT1 A 0 A_JumpIf(User_Counter <= 0,"NULL")
    TNT1 A 0 A_SetUserVar("User_Counter", User_Counter - 1)
	TNT1 AA 0 A_SpawnItemEx("MagnetParticle",random(10,-10),random(10,-10),random(10,-5),frandom(2.0,4.0),frandom(2.0,4.0),frandom(2.0,6.0),random(0,360),SXF_CLIENTSIDE)
	TNT1 A 1
	Loop
  }
}

ACTOR MagnetDeathSmoke
{
  RenderStyle Add
  Scale 0.1
  +NOINTERACTION
  +NOGRAVITY
  +CLIENTSIDEONLY
  Alpha 0.99
  var int User_Counter;
  States
  {
  Spawn:
    TNT1 AA 0 A_SetUserVar("User_Counter", 25)
    TNT1 A 0 A_SpawnItemEx("InstafunShock",0,0,0,0,0,0,0,128,0)
  Looplet:
	TNT1 A 0 A_JumpIf(User_Counter <= 0,"NULL")
    TNT1 A 0 A_SetUserVar("User_Counter", User_Counter - 1)
	TNT1 AA 0 A_SpawnItemEx("InstafunExplode",random(5,-5),random(5,-5),random(5,-5),0,0,0,random(0,360),SXF_CLIENTSIDE)
	TNT1 A 1
	Loop
  }
}

ACTOR MagnetDeathGLDEF
{
	+NOINTERACTION
	+NOGRAVITY
	+CLIENTSIDEONLY
	States
	{
	Spawn:
	TNT1 A 42
	Stop
	}
}